<%@page import="org.beetl.core.Function"%>
<%@page import="com.don.beetl.ext.fn.*"%>
<%@page import="org.beetl.core.resource.WebAppResourceLoader"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.beetl.core.resource.ClasspathResourceLoader"%>
<%@page import="org.beetl.core.Configuration"%>
<%@page import="org.beetl.core.GroupTemplate"%>
<%@page import="org.beetl.core.Template"%>
<%@page import="com.don.beetl.bean.Teacher"%>
<%@page import="com.don.beetl.bean.Student"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<title></title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="krumo/skins/orange/skin.min.css" rel="stylesheet" />
		<script src="krumo/krumo.min.js" type="text/javascript"></script>
	</head>
	<body>
	本功能类似Eclipse debug效果: <br><img alt="" src="screenshot/1.png"> <br>
	<font color=red ><b>应用范围：模版开发人员，通过查看页面可使用变量，结合相关标签 遍历或直接打印指定变量，进而可以更好开发模版<BR>
	          当然也方便开发人员调试页面上变量及其对应数值是否正确</b></font><BR>
	beetl模版代码示例:<BR>
	<div style="background-color: #ccc;">
	var param1 = '{"id":"100001","name":"张三"}';<BR>
	var param2 = '{"id":"100002","name":"李四"}';<BR>
	devel(param1,param2,school,session,cookies);//打印指定变量<BR>
	develGlobalVar(param1,param2);//默认打印全局变量<BR>
	</div>
		<%
			WebAppResourceLoader resourceLoader = new WebAppResourceLoader();
			Configuration cfg = Configuration.defaultConfiguration();
			GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
            gt.registerFunction("develGlobalVar", new DevelGlobalVar());
    		gt.registerFunction("devel", new Devel());
			Template t = gt.getTemplate("devel.html");
			//全局变量
			t.binding("session", request.getSession());
			t.binding("cookies", request.getCookies());

			List list = new ArrayList();
			Teacher teacher = new Teacher();
			teacher.setDate(new Date());
			teacher.setId("001");
			teacher.setName("教师1");
			teacher.setSex(true);
			teacher.setAge(30);

			for (int i = 0; i < 30; i++) {
				Student stu = new Student();
				stu.setAge(new Random().nextInt(20));
				stu.setName("X学生" + i);
				stu.setDate(new Date());
				stu.setId("A001" + i);
				stu.setSex((i % 2 == 0) ? true : false);
				teacher.addStudent(stu);
			}
			list.add(teacher);

			teacher = new Teacher();
			teacher.setDate(new Date());
			teacher.setId("002");
			teacher.setName("教师2");
			teacher.setSex(false);
			teacher.setAge(20);

			for (int i = 0; i < 45; i++) {
				Student stu = new Student();
				stu.setAge(new Random().nextInt(20));
				stu.setName("Y学生" + i);
				stu.setDate(new Date());
				stu.setId("B001" + i);
				stu.setSex((i % 2 == 0) ? true : false);
				teacher.addStudent(stu);
			}
			list.add(teacher);
			t.binding("school", list);

			String str = t.render();
			out.print(str);
		%>
	</body>
</html>